﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using Hi_Baidu.Entry.CollectionObject;

namespace Hi_Baidu.Timer
{
    /// <summary>
    ///     提供了删除用户分组的超时计算和相关操作
    /// </summary>
    class DeleteItemTimeOutEvent : TimeOutEvent
    {
        private byte[] username;
        private byte[] ItemId;

        /// <summary>
        ///     提供了删除用户分组的超时计算和相关操作
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="ItemId">分组Id</param>
        /// <param name="Key">唯一表示</param>
        /// <param name="Interval">超时器触发间隔</param>
        /// <param name="TryCount">总共尝试次数</param>
        public DeleteItemTimeOutEvent(byte[] username, byte[] ItemId, String Key, int Interval, int TryCount) : base(Key, Interval, TryCount)
        {
            this.username = username;
            this.ItemId = ItemId;
            this.OnTryFull += new EventHandler<EventArgs>(DeleteItemTimeOutEvent_OnTryFull);
            this.OnTick += new EventHandler<EventArgs>(DeleteItemTimeOutEvent_OnTick);
        }

        void DeleteItemTimeOutEvent_OnTick(object sender, EventArgs e)
        {
            //重试删除
            Hi_Baidu.ProcessModel.UpdateProcessModel.DeleteItem(this.username, this.ItemId);
        }

        void DeleteItemTimeOutEvent_OnTryFull(object sender, EventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new PUBLIC_DELEGATE(Globle.ShowWindow));
        }
    }
}
